﻿using System;
using System.Globalization;
using System.IO;

namespace VolgaTransTelecomClient
{
    internal static class Logger
    {
        #region Constants
        public const string FileName = "exception.log";
        #endregion

        #region Methods
        /// <summary>
        /// Writes the error.
        /// </summary>
        /// <param name="ex">The exception.</param>
        internal static void WriteError(Exception ex)
        {
            WriteError(ex.ToString());
        }

        /// <summary>
        /// Writes the error.
        /// </summary>
        /// <param name="message">The message.</param>
        internal static void WriteError(string message)
        {
            using (FileStream fs = new FileStream(FileName, FileMode.Append, FileAccess.Write))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.WriteLine("[ERROR]:[{0}]:{1}", DateTime.Now.ToString(CultureInfo.InvariantCulture), message);
                }
            }
        }
        #endregion
    }
}
